/**
 * 
 */
package com.xbjtech.controller;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.xbjtech.util.StringUtils;

import lombok.extern.slf4j.Slf4j;

/**
 * @author Administrator
 *
 */
@Controller
@RequestMapping("/sms")
@Slf4j
public class SmsController {
	
	public final static String CODE_FLAG = "mobile_code";
	
	/**
	 * 【百度】验证码：123112，这是当前用户登陆的验证码，请不要随意给他人。
	 * 
	 * @param mobile
	 * @return
	 */
	@GetMapping("/send")
	@ResponseBody
	public String sendMsg(
			@RequestParam(required = true) String mobile) {
		String code = StringUtils.randomNumString(6);
		Session session = SecurityUtils.getSubject().getSession();
		session.setAttribute(CODE_FLAG, code);
		log.info("接收短信的手机号：{}", mobile);
		log.info("【安徽修补匠】验证码：{}，这是当前用户登陆的验证码，请不要随意给他人。", code);
		return "{\"msg\":\"true\"}";
	}

}
